Time settings:

extern bool UseTimeFilter = true;
extern string FirstTradingHour="08:00";
extern string FirstTradingHour_v2="05:00";
extern string LastTradingHour="22:00";

FirstTradingHour is the first hour for the original strategy.
FirstTradingHour_v2 is the first hour for strategy V2.

----

extern int TLBreakoutMinPips = 6;
extern int TLBreakoutMaxPips = 15;

when there is a breakout, price must be between these limits,
at least 6 pips above/below the TL but no more than 15 pips.

----
extern double Lots = 0.1;
Trade size is 0.1 Lots.

extern int StopAddPips = 6;

pips added to SL.

extern int TPSubsPips = 3;

TP is "TPSubsPips" pips less. this is for cases when price only goes near the target but does not reach it.

extern int MinPSRDist = 5;
extern int MaxPSRDist = 15;

this is the distance where other SR, TL, Pivot levels are looked, if there is
any close to TL then the breakout point is changed to that point.
it is bit complex to give good short details, later will be explained.
in the comment these levels are written as "objects near upper/lower TL".

extern bool DisplayHTLs = true;
- display of TLs H1 and higher 
(here H1 TL is not the one according to the strategy rules)
these TLs are thin plotted lines, named H1_R, H4_R, D1_R, W1_R, H1_S, H4_S, D1_S, W1_S

----

extern bool PivotBrokerTime = false;
- true: uses broker time midnight pivot
- false: uses "PivotStartingHour" pivot (broker time)

extern string PivotStartingHour="00:00";
(Pivot staring hour is not interesting for weekly or monthly pivots.)

extern bool UseMidPivots=false;
extern bool UseWeeklyPivots=true;
extern bool UseMonthlyPivots=true;

use of Midpoints, Weekly, Monthly pivots.

----

extern bool CheckHistoryLoad=true;
extern int CheckHistoryOnLoad = 11000;
extern int CheckLoadedBars=1000;

extern bool OnlyOneTradeADay = false;   // Trade only one breakout in one direction
- true: only one breakout traded.

extern int OOTD_period = PERIOD_M5;     // History check periods
- checks in loaded order history if there was an order opened/closed today (here today is from the opening of the last D1 bar).
checks in every 5 minutes. there is also a simple check rule: when the sum of order tickets changes.

extern bool TradeBrokenTLs = false;     // Do not Trade already Broken Trendlines
true: trades only not broken TLs
TL is broken when price is "TLBreakoutMinPips" lower/higher than TL.

extern bool ChangeBrokenTLColor = false;
extern color BrokenUPTL=LightBlue;
extern color BrokenDNTL=Orange;

if "ChangeBrokenTLColor" is true, broken TL color will be changed to BrokenUPTL, BrokenDNTL.

extern bool loggingenabled = true;
the comment is printed into the MT4 experts log when an order is opened or a trade is closed.

extern bool loggingsnapshot = true;
true: a snapshot is created in experts/files directory. the terminal may seem frozen for 1 or 2 seconds. it is done when: a new order is opened, an order is closed, and at the start of every H1 bar. also when the sum of order tickets changes.

----

bool TradeType1 = true;     // 1: Exit1stPSR
- target set to next pivot.
bool TradeType2 = true;     // 2: ExitAfter3HRS
- no target set, the trade is closed after 3 hrs.
the 3 hours should be counted from the first bar that closes above/below the TL after the trade is opened,
not simply from the bar when the trade is opened. this needs more testing.
the trade type 1 is also closed after 3 hours if target is not reached.

bool TradeType3 = true;     // 3: Trail previous bar high/low
- no target set, trade is trailed with previous bar H/L
(maybe it is better to start trailing after the first 3 hours.)

bool TradeType4 = false;    // 4: Pending Orders (buy/sell STOP)
- not working, please do not use.

extern bool UseSetup1 = false;  // M5 swing high/low break
extern bool UseSetup2 = false;  // 2x M5 bar close above/below TL
extern bool UseSetup3 = true;  // simple price x pips above/below TL

setup 3 is like a triggered pending order, but it is a normal market order.
opens when price is above/below TL more than "TLBreakoutMinPips" but no
more than "TLBreakoutMaxPips"
maxpips maybe useful when price simply jumps much pips eg. after news releases.

the other setups are experimental now.
setup 1 is triggered when price exceeds the first M5 swing H/L above/below TL.
setup 2 is triggered when there are 2x M5 bars closing above/below TL.

----
parameters for SL:

extern int MinSL = 10;
extern int MaxSLPerTrade = 100;
extern bool NoTradeOverMaxSL = false;
extern int MaxTotalOpenSL = 1000;

these are for preventing entering into trades with too high SL or open more trade. the SL calculation is quite simple according to the original rules: H/L of TL breaking bar, some cases adjusted to nearest swing H/L. I managed to take it complicated :-) so right now is simply not OK, usually more than should be.

----

extern bool UseTrailingStop = true;
extern int TrailingStop = 30;
if true, trailing stop is used for all type of orders.

extern bool UseSLnotExit = true;
extern int SLExitPips=3;
if true, trades will be not closed but trailed from "SLExitPips" distance.

extern int BELockAtPips = 30;                  
if higher than 0: breakeven lock at x pips (all ordertype)
0: not used

----

extern bool fixedspread = true;
extern int maxspread = 8;

for variable spread brokers: fixedspread=false;
this is for not opening orders when spread is higher than maxspread.
for variable spread brokers the maxspread is taken from the "avgspread" array
what is not external parameter, values may be changed in the code.
I made a simple Marketinfo EA that calculated the min, max, average spreads.
maybe this makes not much use with variable spread brokers because the spread
may change between reading and placing the order.
for variable spread this can be set to "true" as well and this feature will not be used.

----
extern int TPShift = 1;      // Trade Type 1
for OrderType1: if 1 target is shifted to the next pivot level when is reached
within the 1st bar of the breakout.

extern bool UseFixedTarget = false;
- if true, target is taken from "FixedTPTargets" array.

extern int MagicNRMin = 170000;
extern int MagicNRMax = 180000;
the order MagicNR is between these values.
it is calculated simply, after "17" two digits includes the nr. of the pair,
the last digit is the OrderType.

the pair nr. is the place in "tpairs" array. 
the values in this place are taken from other arrays.
for example: EURUSD is the first in tpairs, the first value will be
used from avgspreads, FixedTPTargets arary.

----

filtering: I have a complex configurable MTF filter set, I included a small part here.
you may select wich filters to use on which timeframes.
displayed info is OK, trade filtering is not tested.

these are the filters:

1: PPMA 1,3 crossover: a simple MA (1,3 period) crossover where price is set to typical price ((H+L+C)/3).
I have read about this in the book: "John L. Person - Forex Conquered. High Probability Systems and Strategies for Active Traders".
http://olesiafx.com/Forex-Conquered-High-Probability-Systems-and-Strategies-for-Active-Traders-JOHN-L-PERSON-WILEY/49.The-pivot-point-moving-average-forex-trading-system.html

2: MA crossover: MA types and periods may be changed, default EMA 9,18
3: price and MA: close price above/below the MA
default: 200 EMA - this is used for strategy V2.

4: MACD hist. level +/-
5: MACD crossover
6: RSI above/below 50
7: CCI above 100/below -100

8: Pivot Point:   extern bool TradeOnlyPivotDir=false;  
- above PP only BUY / below PP only SELL 

in case of filters 1-7 the value of shifts 1 and 0 are taken.
shift 0 value changes until the bar is closed, so the displayed info may also change. a displayed UP or DN dir is based on the same shift 0 and 1 values.

I don't know if any higher timeframe filtering makes a good use with this strategy...

---

The EA checks loaded history. sometimes happens that many days, months, etc. are missing from the history,
it is written into comment and log.
Trendline calculation needs Higher Swing Highs and Lower Swing Lows. 
If there is a swing H/L and no other swing H/L is found, higher timeframe data
is searched to find if there may be another valid swing to use for TL.
if any found it is written into comment and log with calculated H1 chart position.
(it is simple to use these values as if there is a TL, but not implemented yet.)
This happens when prices reach new weekly or monthly highs or lows.
